package com.zmn.uac.client;

import com.zmn.common.dto2.ResponseDTO;
import com.zmn.uuc.common.constant.DubboConsts;
import com.zmn.uuc.common.dro.user.UserThirdBaseDRO;
import com.zmn.uuc.dubbo.interfaces.user.UserThirdListRemoteService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

/**
 * @title: 个人用户三方账户查询Dubbo接口
 * @author:Rananquan
 * @Date:2022/6/9 17:54
 */
@Slf4j
@Component
public class UserThirdListClient {

    @DubboReference(version = DubboConsts.INTERFACE_VERSION, check = false)
    UserThirdListRemoteService userThirdListRemoteService;


    /**
     * 根据opeinId，appId和mobile获取三方账户信息
     * @param openId openId
     * @param appId 第三方应用id
     * @param mobile 手机号
     * @return
     */
    public UserThirdBaseDRO getThirdByOpenIdAndAppIdAndMobile(String openId,String appId,String mobile){
        log.info("根据openId，appId和mobile获取三方账户信息入参，openId：{}，appId：{}，mobile：{}",openId,appId,mobile);
        ResponseDTO<UserThirdBaseDRO> userThirdBaseResponse = userThirdListRemoteService.getThirdByOpenIdAndAppIdAndMobile(openId, appId, mobile);
        if(!userThirdBaseResponse.isSuccess()){
            log.error("根据openId，appId和mobile获取三方账户信息请求失败，失败原因：{}",userThirdBaseResponse.getMessage());
        }

        UserThirdBaseDRO userThirdData = userThirdBaseResponse.getData();
        log.info("根据openId，appId和mobile获取三方账户信息返回response：[{}]",userThirdData);

        return userThirdData;
    }
}
